<template>
  <div ref="sheetRef" class="sheet"></div>
</template>
<script setup lang="ts">
import { onMounted, ref } from 'vue';
import '@univerjs/presets/lib/styles/preset-sheets-core.css';
import UniverPresetSheetsCoreZhCN from '@univerjs/presets/preset-sheets-core/locales/zh-CN';
import { UniverSheetsCorePreset } from '@univerjs/presets/preset-sheets-core';
import { createUniver, defaultTheme, LocaleType, merge } from '@univerjs/presets';
//批量保存表格
defineOptions({
  name: 'BatchSaveSheet',
});
const sheetRef = ref<HTMLElement>();

onMounted(() => {
  const { univerAPI } = createUniver({
    locale: LocaleType.ZH_CN,
    locales: {
      [LocaleType.ZH_CN]: merge({}, UniverPresetSheetsCoreZhCN),
    },
    theme: defaultTheme,
    presets: [
      UniverSheetsCorePreset({
        container: sheetRef.value,
        header: true,
        footer: true,
      }),
    ],
    plugins: [],
  });

  univerAPI.createWorkbook({
    name: 'Test Sheet',
    sheets: {
      sheet1: {
        id: 'sheet1',
        name: '数据库字段标准',
        defaultRowHeight: 32,
        rowCount: 50,
        columnCount: 10,
        cellData: {
          0: {
            0: {
              v: 'Hello Univer!',
            },
          },
        },
      },
    },
  });
});
</script>
<style lang="scss" scoped>
.sheet {
  width: 100%;
  height: 100%;
}
</style>
